import {expect} from 'chai'
import {readFile,checkCoverageFileExist} from '../src/utils'

describe('readFile', () => {
  it('should throw error if the file does not exist', async () => {
    try{
        await readFile('non-existent-file.txt')
        expect.fail('should throw an error')
    } catch (error:any) {
        expect(error.message).to.equal(`ENOENT: no such file or directory, open 'non-existent-file.txt'`)
    }
  })
})

describe('checkCoverageFileExist', async () => {
    it('should throw error if the file does not exist', async () => {
        try{
            await checkCoverageFileExist('non-existent-file.txt')
            expect.fail('should throw an error')
        } catch (error:any) {
            expect(error.message).to.equal(`Report file non-existent-file.txt does not exist, please rename your test report`)
        }
    })
})